package com.lolongmaps.test;

import java.util.Random;

public class Generator {
	
	private final String[] RESTAURANT_TYPES = {"Fastfood", "Restaurant", "Cafe", "Bakeshop, Desserts and Delicacies"};
	private final String[] FOOD_TYPES = {"American", "Coffee", "Chinese", "Dessert", "Filipino", "Italian","Japanese", "Korean", "Bread"};
	private final String[] AREA_TYPES = {"Ayala Central Business District", "Glorietta 5"};
	
	private String generatedRestaurant, generatedFood, generatedArea;
	
	private Random random;
	private int randomNumber, restaurantNumber, foodNumber, areaNumber, restaurantIndex, foodIndex, areaIndex;
	
	public Generator() {
	
		this.random = new Random();
		
		this.generatedRestaurant = "none";
		this.generatedFood = "none";
		this.generatedArea = "none";
		this.randomNumber = 0;
		this.restaurantNumber = 0;
		this.foodNumber = 0;
		this.areaNumber = 0;
				
	}

	public String getGeneratedRestaurant() {
		return generatedRestaurant;
	}

	public String getGeneratedFood() {
		return generatedFood;
	}

	public String getGeneratedArea() {
		return generatedArea;
	}

	
	public void generateRestaurant() {
		
		this.randomNumber = random.nextInt(RESTAURANT_TYPES.length);
		this.restaurantNumber = randomNumber;
		this.generatedRestaurant = RESTAURANT_TYPES[randomNumber];
		
	}
	
	public void generateFood() {
		
		this.randomNumber = random.nextInt(FOOD_TYPES.length);
		this.foodNumber = randomNumber;
		this.generatedFood = FOOD_TYPES[randomNumber];
		
	}
	
	public void generateArea() {
		
		this.randomNumber = random.nextInt(AREA_TYPES.length);
		this.areaNumber = randomNumber;
		this.generatedArea = AREA_TYPES[randomNumber];
		
	}
	
	public void nullifyStuff(boolean areaFlag, boolean foodFlag, boolean restaurantFlag) {
		
		if(!areaFlag) this.generatedArea = "none";
		if(!foodFlag)this.generatedFood = "none";
		if(!restaurantFlag)this.generatedRestaurant = "none";
		this.restaurantNumber = 0;
		this.foodNumber = 0;
		this.areaNumber = 0;
		
	}

	public int getRestaurantNumber() {
		return restaurantNumber;
	}

	public int getFoodNumber() {
		return foodNumber;
	}

	public int getAreaNumber() {
		return areaNumber;
	}

	
	public int getRestaurantIndex(String s) {
		
		for(int x=0; x<RESTAURANT_TYPES.length; x++) {
			
			if(RESTAURANT_TYPES[x].equals(s))
				this.restaurantIndex = x;
			
		}
		
		return restaurantIndex;
		
	}

	
	public int getFoodIndex(String s) {
		
		for(int x=0; x<FOOD_TYPES.length; x++) {
			
			if(FOOD_TYPES[x].equals(s))
				this.foodIndex = x;
			
		}
		
		return foodIndex;
		
	}

	public int getAreaIndex(String s) {
	
		for(int x=0; x<AREA_TYPES.length; x++) {
		
			if(AREA_TYPES[x].equals(s))
				this.areaIndex = x;
		
		}
	
		return areaIndex;
	
	}
	
}
